package com.geek.water.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.geek.water.entity.Permission;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author chenmin
 * @desc 权限Mapper
 * @date 2025/01/08
 */
public interface PermissionMapper extends BaseMapper<Permission> {

    /**
     * 获取所有权限列表
     * @return 权限列表
     */
    @Select("SELECT * FROM permission ORDER BY id")
    List<Permission> selectAllPermissions();

    /**
     * 获取菜单树（如果使用menu表）
     * @return 菜单列表
     */
    @Select("SELECT m.*, mt.title, mt.hidden, mt.icon " +
            "FROM menu m " +
            "LEFT JOIN meta mt ON m.meta_id = mt.id " +
            "ORDER BY m.priority, m.id")
    List<Object> selectAllMenus();
}
